package com.red.controller.user;

import com.red.dto.AttractionsStatusDTO;
import com.red.dto.HomePageQueryDTO;
import com.red.entity.Attractions;
import com.red.entity.Carousels;
import com.red.result.PageResult;
import com.red.result.Result;
import com.red.service.AttractionsService;
import com.red.vo.AttractionsVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController("userAttractionsController")
@RequestMapping("/user/scenic")
@Slf4j
@ApiModel(value = "景点信息")
public class AttractionsController {
    @Autowired
    private AttractionsService attractionsService;

    /**
     * 获取轮播图全部信息
     * @return
     */
    @GetMapping("/carouselsAll")
    @ApiModelProperty("获取轮播图全部信息")
    public Result<List<Carousels>> getCarouselsAll(){
        List<Carousels> carousels = attractionsService.getCarouselsAll();
        return Result.success(carousels);
    }

    /**
     * 景点全部信息
     * @return
     */
    @GetMapping("/scenicAll")
    @ApiModelProperty("景点全部信息")
    public Result<List<Attractions>> getScenicAll(){

        List<Attractions> attractionsList = attractionsService.getScenicAll();
        return Result.success(attractionsList);
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/scenicPort")
    @ApiModelProperty("分页查询")
    public Result<PageResult> getScenicPort(HomePageQueryDTO dto){
        log.info("分页查询信息:{}",dto);
        PageResult pageResult = attractionsService.PageQuery(dto);
        return Result.success(pageResult);
    }

    /**
     * 是否去过该景点
     * @return
     */
    @PutMapping
    @ApiModelProperty("是否去过该景点")
    public Result is_status(AttractionsStatusDTO dto){
        log.info("接受数据：{}",dto);
        attractionsService.is_Status(dto);
        return Result.success();
    }

    /**
     * 根据ID查询景点
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiModelProperty("根据ID查询景点")
    public Result<AttractionsVO> getById(@PathVariable Long id){

        AttractionsVO attractionsVO = attractionsService.getAttractionById(id);
        return Result.success(attractionsVO);
    }

    /**
     * 根据用户ID查询去过的景点
     * @return
     */
    @GetMapping
    @ApiModelProperty("根据用户ID查询去过的景点")
    public Result<List<Attractions>> selectByUserId(){
        List<Attractions> list = attractionsService.selectByUserId();
        return Result.success(list);
    }
}
